#ifndef __HIZ_INCLUDE__
#define __HIZ_INCLUDE__

#include "UnityCG.cginc"

struct Attributes
{
	float4 posO : POSITION;
	float2 uv : TEXCOORD0;
};

struct Varyings
{
	float4 posC : SV_POSITION;
	float2 uv : TEXCOORD0;
	float4 scrPos: TEXCOORD2;
};

Texture2D _MainTex;
SamplerState sampler_MainTex;

Texture2D _CameraDepthTexture;
SamplerState sampler_CameraDepthTexture;

Varyings vert(in Attributes IN)
{
	Varyings OUT;
	OUT.posC = UnityObjectToClipPos(IN.posO.xyz);
	OUT.uv = IN.uv;

	OUT.scrPos = ComputeScreenPos(OUT.posC);
	return OUT;
}

float4 blit(in Varyings IN) : SV_Target
{
	float camDepth = _CameraDepthTexture.Sample(sampler_CameraDepthTexture, IN.uv).r;
	return float4(camDepth, 0, 0 ,0);
}

float4 reduce(in Varyings IN) : SV_Target
{
	float4 r = _MainTex.GatherRed(sampler_MainTex, IN.uv);
	//float4 g = _MainTex.GatherGreen(sampler_MainTex, IN.uv);

	float minimum = min(min(min(r.x, r.y), r.z), r.w);
	//float maximum = max(max(max(g.x, g.y), g.z), g.w);
	float maximum = max(max(max(r.x, r.y), r.z), r.w);
	return float4(minimum, maximum, 1.0, 1.0);
}
#endif